package com.efast.cafe.portal.controller.api;

import com.efast.cafe.framework.bean.ResultBean;
import com.efast.cafe.framework.controller.AbstractController;
import com.efast.cafe.framework.exception.ServiceException;
import com.efast.cafe.portal.bean.api.PortalApiTreeBean;
import com.efast.cafe.portal.bean.api.PortalApiTreeQueryBean;
import com.efast.cafe.portal.service.api.IPortalApiTreeServcie;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/frame_center/api")
public class PortalApiTreeController extends AbstractController{
	
	@Autowired
	private IPortalApiTreeServcie portalApiTreeServcie;
	
	@RequestMapping("/tree/list")
	public @ResponseBody ResultBean tree(@RequestBody PortalApiTreeQueryBean portalApiTreeBean){
		ResultBean result = new ResultBean();
		result.setSuccess(true);
		try {
			result.setObject(portalApiTreeServcie.queryTree(portalApiTreeBean));
		} catch (Exception e) {
			e.printStackTrace();
			result.setSuccess(false);
			if (e instanceof ServiceException) {
				result.setMessage(e.getMessage());
			} else {
				result.setMessage(FAILURE);
			}
		}
		return result;
	}
	
	
}
